/*
 * 文 件 名:  SetCharacterEncodingFilter.java
 * 版    权:   深圳埃思欧纳信息咨询有限公司版权所有. YYYY-YYYY,  All rights reserved
 * 描    述:   <描述>
 * 修 改 人:  honny.huang
 * 修改时间: 2011-7-1
 * 跟踪单号:  <跟踪单号>
 * 修改单号:  <修改单号>
 * 修改内容:  <修改内容>
 */
package com.common;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * Example filter that sets the character encoding to be used in parsing the
 * incoming request
 */
public class SetCharacterEncodingFilter implements Filter {

    /**
     * Take this filter out of service.
     */
    public void destroy() {

    }
    /**
     * Select and set (if specified) the character encoding to be used to
     * interpret request parameters for this request.
     */
    public void doFilter(ServletRequest request, ServletResponse response,
           FilterChain chain) throws IOException, ServletException {

       request.setCharacterEncoding("utf-8");
       chain.doFilter(request, response);
    }

    public void init(FilterConfig filterConfig) throws ServletException {

    }

}
